﻿using M.ShopMachine.Repository.Interface;
using M.ShopMachine.Write.WebApi.Application.Command.DeviceCommand;
using MediatR;

namespace M.ShopMachine.Write.WebApi.Application.Handler.DeviceHandler
{
    public class UpdStateDeviceHandler : IRequestHandler<UpdStateDeviceCommand, int>
    {
        private readonly IDeviceRepository deviceRepository;

        public UpdStateDeviceHandler(IDeviceRepository deviceRepository)
        {
            this.deviceRepository = deviceRepository;
        }

        public async Task<int> Handle(UpdStateDeviceCommand request, CancellationToken cancellationToken)
        {
            return await deviceRepository.UpdStateDeviceAsync(request.id, request.State);
        }
    }
}
